package com.xiaoyu.im.client.proxy;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.netease.nimlib.sdk.RequestCallback;
import com.xiaoyu.im.IMCallback;
import com.xiaoyu.im.datamodel.messagesync.MessageFetchResult;
import com.xiaoyu.im.client.proxy.AbstractProxy.QueryDirection.DirectionDef;
import com.xiaoyu.im.client.proxy.nim.AntiSpamResult;
import com.xiaoyu.im.datamodel.AppMessage;
import com.xiaoyu.im.datamodel.AppMessageReceipt;
import com.xiaoyu.im.datamodel.IMVendorType;
import com.xiaoyu.im.datamodel.auth.IMTokenInfo;
import com.xiaoyu.im.datamodel.vendors.VendorConversationUnique;

import in.srain.cube.util.internal.AppObserver;

import java.util.List;
import java.util.Set;

public interface IMProxy {

    @NonNull
    IMTokenInfo getSuccessIMTokenInfo();

    @IMVendorType.IMVendorTypeDef
    String getVendorType();

    void setUp();

    void login();

    void logout();

    void sendMessage(AppMessage message, IMCallback<AppMessage> callback);

    void sendMessageReceipt(AppMessage message);

    void recallMessage(AppMessage message, IMCallback<Void> callback);

    void observeReceiveMessage(AppObserver<List<AppMessage>> receiveMessageObserver);

    void observeCustomNotification(AppObserver<List<AppMessage>> customNotificationObserver);

    void observeBroadcastMessage(AppObserver<String> broadcastMessageObserver);

    void observeRecallMessage(AppObserver<AppMessage> recallMessageObserver);

    void observeOnlineStatus(AppObserver<String> onlineStatusObserver);

    void observeOnlineUserAccounts(AppObserver<Set<String>> onlineUserAccountsObserver);

    void observeMessageReceipt(AppObserver<List<AppMessageReceipt>> messageReceiptObserver);

    boolean isOnline();

    boolean shouldNotLoginAgain();

    String getOnlineStatus();

    AntiSpamResult checkLocalAntiSpam(String content, String replacement);

    int getUnreadMessageCount(String chatId);

    void clearUnreadCount(String chatId);

    void queryMessagesFromRemote(int limit, String chatId, long fromTime, long toTime, @DirectionDef int direction, IMCallback<List<AppMessage>> callback);

    List<AppMessage> queryMessagesFromRemote(int limit, String chatId, long fromTime, long toTime, @DirectionDef int direction) throws Throwable;

    MessageFetchResult onFetch(String chatId, long fromTime, long toTime, @DirectionDef int direction) throws Throwable;

    void onFetchFinish(String chatId, List<AppMessage> messages);

    void resubscribeUsersOnlineStatus(List<String> oldAccids, List<String> newAccids);

    void subscribeUsersOnlineStatus(List<String> accids);

    void unsubscribeUsersOnlineStatus(List<String> accids, RequestCallback<Void> callback);

    @Nullable
    VendorConversationUnique toConversationUnique(String chatId);
}
